<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加/修改页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../component/elementUI/index.css">
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
    <link rel="stylesheet" href="../../../style/wangeditor.css">
    <link rel="stylesheet" href="../../../style/index.css">
</head>

<body>
    <div id="app" v-cloak>
        <div class="add">
            <div class="header">
                <span>{{(action == 'Add'?'添加':'修改')}}规则信息</span>
            </div>
            <div class="main" style="padding: 0 15px;">
                <!-- 配置属性, 目前仅支持 单主表 多子表 结构 -->
                <div id="form" :data-options="JSON.stringify({'tableName':'tracecode_rules','formName':'dataForm' ,'primaryKey':'Rules_SerialNumber'})">
                    <!-- 子表 -->
                    <div :data-options="JSON.stringify({'tableName':'tracecode_rules_detail','formName':'childDataForm', 'parentTableName':'tracecode_rules'})"></div>
                </div>
                <div class="table_titel">
                    <div class="titel">规则名称</div>
                </div>
                <el-form :model="dataForm" ref="form" :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">规则名称</div>
                            </template>
                            <el-form-item prop="Rules_Name" :rules="[{ required: true, message: '请输入规则名称', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Rules_Name" placeholder="请输入规则名称" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                          <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">规则长度</div>
                            </template>
                            <el-form-item prop="Code_length" :rules="[{ required: true, message: '请输入规则长度', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Code_length" placeholder="请输入规则长度" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">码流水号长度</div>
                            </template>
                            <el-form-item prop="Code_Seriallength" :rules="[{ required: true, message: '请输入码流水号长度', trigger: 'blur' }]">
                                <el-input @change="CodeNumberLength" v-model.trim="dataForm.Code_Seriallength"   clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">码流水号数值</div>
                            </template>
                            <el-form-item prop="Code_Serial" :rules="[{ required: true,  trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Code_Serial" disabled clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">备注</div>
                            </template>
                            <el-form-item prop="Memo" :rules="[{ required: true, message: '请输入备注', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Memo" placeholder="请输入备注" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>         
                </el-form>
                <div class="table_titel">
                    <div class="titel">码段类型</div>
                     <div class="operation">
                        <el-button type="primary" size="small" @click="handleAdd('childDataForm')">新增</el-button>
                        <el-button type="danger" size="small" @click="handleRemove('childDataForm')">删除</el-button>
                    </div>
                </div>

                <el-form :model="{childDataForm:childDataForm.filter(i=>i.Row_Status != '1')}" ref="childForm" :inline-message="true" style="width: 100%">
                    <el-descriptions :column="2" size="large" border v-for="(item,index) in childDataForm.filter(i=>i.Row_Status != '1')" :key="index">
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">码段类型</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Code_Type`"
                                :rules="[{ required: true, message: '请输入码段类型', trigger: 'change' }]">
                                 <el-select   @change="(val) => handleCheck(val, item, index)"  v-model.trim="item.Code_Type" placeholder="请选择码段类型" style="width: 100%;" clearable filterable>
                                    <el-option  v-for="(item,index) in code_type" :key="index" :label="item.name" :value="item.code" />
                                </el-select>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">码段值</div>
                            </template>
                            <el-form-item  :prop="`childDataForm.${index}.Code_Value`" :rules="[{ required: true, message: '请输入码段值', trigger: 'blur' }]">
                                <el-input   v-model.trim="item.Code_Value" placeholder="请输入码段值"  clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item required">备注</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Memo`" :rules="[{ required: true, message: '请输入备注', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Memo" placeholder="请输入备注" clearable></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                    </el-descriptions>
                </el-form>
            </div>
            <div class="footer">
                <el-button size="medium" @click="handleBack">返回</el-button>
                <el-button size="medium" type="primary" plain @click="handleSubmit" :loading="loading">提交</el-button>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../../../utils/wangeditor.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.full.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.min.js"></script> 
    <script type="text/javascript" src="../../../utils/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../utils/vue.min.js"></script>
    <script type="text/javascript" src="../../../utils/vuex.min.js"></script>
    <script type="text/javascript" src="../../../component/elementUI/index.js"></script>
    <script type="text/javascript" src="../../../utils/components.js"></script>
    <script type="text/javascript" src="../../../utils/compressor.js"></script>
    <script type="text/javascript" src="../../../utils/validity.js"></script>
    <script type="text/javascript" src="../../../utils/utils.js"></script>
    <script type="text/javascript" src="../../../utils/http.js"></script>
    <script type="text/javascript" src="js/add.js"></script>
</body>

</html>